package design.graduation.novelsystem.model.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import design.graduation.novelsystem.constant.Constant;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author: 洪少尉
 * @Date: 2020/4/14 00:21
 * @Description: 装载返回前端Json数据
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultObj implements Serializable {

	/**
	 * 添加
	 */
	public static final ResultObj ADD_SUCCESS = new ResultObj(Constant.SUCCESS_CODE,"添加成功");
	public static final ResultObj ADD_ERROR = new ResultObj(Constant.ERROR_CODE,"添加失败");
	/**
	 * 删除
	 */
	public static final ResultObj DELETE_SUCCESS = new ResultObj(Constant.SUCCESS_CODE,"删除成功");
	public static final ResultObj DELETE_ERROR = new ResultObj(Constant.ERROR_CODE,"删除失败");
	public static final ResultObj DELETE_IDS_NULL = new ResultObj(Constant.ERROR_CODE,"传入id不能为空");
	/**
	 * 更新
	 */
	public static final ResultObj UPDATE_SUCCESS = new ResultObj(Constant.SUCCESS_CODE,"更新成功");
	public static final ResultObj UPDATE_ERROR = new ResultObj(Constant.ERROR_CODE,"更新失败");
	/**
	 * 分配角色/权限
	 */
	public static final ResultObj DISPATCH_SUCCESS = new ResultObj(Constant.SUCCESS_CODE,"分配成功");
	public static final ResultObj DISPATCH_ERROR = new ResultObj(Constant.ERROR_CODE,"分配失败");
	/**
	 * 重置
	 */
	public static final ResultObj RESET_SUCCESS = new ResultObj(Constant.SUCCESS_CODE,"重置成功");
	public static final ResultObj RESET_ERROR = new ResultObj(Constant.ERROR_CODE,"重置失败");
	/**
	 * 验证登录
	 */
	public static final ResultObj IS_LOGIN = new ResultObj(Constant.SUCCESS_CODE,"用户已登录");
	public static final ResultObj UN_LOGIN = new ResultObj(Constant.ERROR_CODE,"用户未登录");
	/**
	 * 验证密码
	 */
	public static final ResultObj SUCCESS_PASSWORD = new ResultObj(Constant.SUCCESS_CODE,"原密码正确");
	public static final ResultObj ERROR_PASSWORD = new ResultObj(Constant.ERROR_CODE,"原密码不正确");
	/**
	 * 小说收录
	 */
	public static final ResultObj INCLUDE_SUCCESS = new ResultObj(Constant.SUCCESS_CODE,"收录成功");
	public static final ResultObj INCLUDE_ERROR = new ResultObj(Constant.ERROR_CODE,"收录失败");
	/**
	 * 批量上架
	 */
	public static final ResultObj BATCH_UP_SUCCESS = new ResultObj(Constant.SUCCESS_CODE,"批量上架成功");
	public static final ResultObj BATCH_UP_ERROR =  new ResultObj(Constant.ERROR_CODE,"批量上架失败");
	/**
	 * 批量下架
	 */
	public static final ResultObj BATCH_DOWN_SUCCESS = new ResultObj(Constant.SUCCESS_CODE,"批量下架成功");
	public static final ResultObj BATCH_DOWN_ERROR =  new ResultObj(Constant.ERROR_CODE,"批量下架失败");
	/**
	 * 爬虫
	 */
	public static final ResultObj START_CRAWLER = new ResultObj(Constant.SUCCESS_CODE,"正在启动，稍后请点击查看爬虫状态，确认是否启动成功");
	public static final ResultObj START_CRAWLER_EEOR = new ResultObj(Constant.ERROR_CODE,"未启动");
	public static final ResultObj KILL_CRAWLER = new ResultObj(Constant.SUCCESS_CODE,"正在停用，稍后请点击查看爬虫状态，确认是否停用成功");
	/**
	 * 状态码
	 */
	private Integer code;
	/**
	 * 状态信息
	 */
	private String msg;
	/**
	 * 数据
	 * 实体类与json互转的时候 属性值为null的不参与序列化
	 */
	@JsonInclude(JsonInclude.Include.NON_NULL)
	private Object data;

	/**
	 * 构造状态码、状态信息
	 * @param code :状态码
	 * @param msg :状态信息
	 */
	public ResultObj(Integer code, String msg) {
		this.code = code;
		this.msg = msg;
	}
}
